<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<script src="js/jquery-3.5.1.js" type="text/javascript" charset="utf-8"></script>
	</head>
	<body>
		<label>书名:</label>
		<input type="text" name="book_Name" id="" value="" placeholder="输入书名"/>
		<br>
		<label>价格:</label>
		<input type="text" name="book_Price" id="" value="" placeholder="输入价格"/>
		<br>
		<label>数量:</label>
		<input type="text" name="book_Count" id="" value="" placeholder="输入数量"/>
		<br>
		<input type="button" name="save" id="" onclick="save()" value="保存"/>
		<script type="text/javascript">
			let add_book = JSON.parse(localStorage.getItem("add_book"));
			function save(){
			let book_Name = $("input[name='book_Name']").val();
			let book_Price = $("input[name='book_Price']").val();
			let book_Count = $("input[name='book_Count']").val();
			let new_book =
			{
				id:1,
				name:book_Name,
				price:book_Price,
				count:book_Count
			};
			console.log(new_book);
			add_book.push(new_book);
			localStorage.setItem("new_book",JSON.stringify(add_book));
			window.location.href="index.html";
			}
		</script>
	</body>
</html>
